package rigidbody;

/**
 * The SimulationObject class is an abstract base class representing an
 * object or concept that may be simulated in our simulator.
 *
 * @author Jeran Fox
 * @author Matthew Cong
 * @author Teddy Ni
 * @author Yunfeng Bai
 */
public class SimulationObject
{
	/**
     * Next object ID.
     */
    private static int NextId = 0;
    public static void ResetNextId() { NextId = 0; }

    /**
     * A unique object ID.
     */
    private int _id;
    
    /**
     * A name. Useful for debugging.
     */
    private String _name;

    /**
     * Flag to control whether debugging information should be displayed.
     */
    private boolean _isDebug;

    /**
     * Flag to control whether object is being simulated or not.
     */
    private boolean _isActive;

    /**
     * Creates a new simulation object with default name.
     */
    public SimulationObject()
    {
        this(null);
    }

    /**
     * Creates a new simulation object with given name.
     *
     * @param String name that identifies this object
     */
    public SimulationObject(String name_)
    {
        _id = NextId++;
        _name = (name_ != null) ? name_ : "Object " + _id;
    }

    /**
     * Get object's unique ID.
     *
     * @return int
     */
    public final int getId()
    {
        return _id;
    }
    
    /**
     * Set the object's id, ***DEBUG ONLY***.
     */
    public void setId(int id)
    {
    	_id = id;
    }

    /**
     * Get object's name string.
     *
     * @return String
     */
    public final String getName()
    {
        return _name;
    }

    /**
     * Get whether object is debugging or not.
     *
     * @return boolean
     */
    public final boolean isDebugging()
    {
        return _isDebug;
    }

    /**
     * Set debugging on or off.
     *
     * @param boolean true to start debugging and false to stop
     */
    public final void setDebugging(boolean isDebug_)
    {
        _isDebug = isDebug_;
    }

    /**
     * Get whether object is simulated or not.
     *
     * @return boolean
     */
    public final boolean isActive()
    {
        return _isActive;
    }

    /**
     * Set the object to be active (simulated) or inactive.
     *
     * @param boolean true to set active and false to not
     */
    public final void setActive(boolean isActive_)
    {
        _isActive = isActive_;
    }

    /**
     * Render debugging information.
     */
    public void render()
    {
    }
    
    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + _id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SimulationObject other = (SimulationObject) obj;
		if (_id != other._id)
			return false;
		return true;
	}
}
